#!/usr/bin/python

import itertools
import median
import unittest


def AllOptions():
  output = set()
  for perm in itertools.combinations_with_replacement([1, 2, 3], 3):
    for comb in itertools.permutations(perm, 3):
      output.add(comb)
  for node in sorted(output):
    yield node


class TestMedian(unittest.TestCase):

  def testBiggest1(self):
    for testcase in AllOptions():
      self.assertEquals(max(testcase), median.Biggest1(*testcase))

  def testBiggest2(self):
    for testcase in AllOptions():
      self.assertEquals(max(testcase), median.Biggest2(*testcase))

  def testMedian(self):
    for testcase in AllOptions():
      self.assertEquals(sorted(testcase)[1], median.Median(*testcase))

  def testMedian2(self):
    for testcase in AllOptions():
      self.assertEquals(sorted(testcase)[1], median.Median2(*testcase))

  def testSmallest(self):
    for testcase in AllOptions():
      self.assertEquals(min(testcase), median.Smallest(*testcase))

if __name__ == '__main__':
  unittest.main()

